cmake_minimum_required(VERSION 3.7)
project(xnet)

# 检查当前操作系统
if(WIN32)
    # 在Windows下
    link_directories(
        # uncomment the following line as needed for your setup
        #${PROJECT_SOURCE_DIR}/lib/npcap/Lib/x64   # for 64-bit Windows
        ${PROJECT_SOURCE_DIR}/lib/npcap/Lib       # for 32-bit Windows
    )

    include_directories(
        ${PROJECT_SOURCE_DIR}/lib/npcap/Include
    )
else()
    # 在Linux下
    # 可能需要指定libpcap的路径或其他Linux特定头文件目录
    # include_directories(/usr/include/pcap)
endif()

include_directories(
    ${PROJECT_SOURCE_DIR}
    ${PROJECT_SOURCE_DIR}/src/xnet_app
    ${PROJECT_SOURCE_DIR}/src/xnet_tiny/include
    ${PROJECT_SOURCE_DIR}/lib/xnet
)

# Search through the "src" directory to list all source files
file(GLOB_RECURSE SOURCE_LIST "src/*.c" "src/*.h")

# Add these source files to the project
add_executable(${PROJECT_NAME} lib/xnet/pcap_device.c ${SOURCE_LIST})

# Link libraries based on the operating system
if(WIN32)
    # Under Windows
    target_link_libraries(${PROJECT_NAME} wpcap Packet)
else()
    # Under Linux
    target_link_libraries(${PROJECT_NAME} pcap)
endif()
